package sz.szsmk.citizencard.ui.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.chenenyu.router.annotation.Route;
import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.ui.base.IBaseActivity;
import sz.szsmk.citizencard.util.PubUtils;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/7/21 14:39
 * description:
 */
@Route("modifyUser")
public class ModifyUserInfoActivity extends IBaseActivity implements View.OnClickListener {

    private ImageView back;
    private Button upLoad;
    private EditText editText;

    @Override
    protected int attachLayoutRes() {
        return R.layout.modify_info_activity;
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initViews() {
        back = (ImageView) findViewById(R.id.back);
        upLoad = (Button) findViewById(R.id.set_nick_upload);
        editText = (EditText) findViewById(R.id.et_nickname);
        TextView title = (TextView) findViewById(R.id.setting_title);
        title.setText("修改昵称");
        upLoad.setOnClickListener(this);
        back.setOnClickListener(this);
    }

    @Override
    protected void updateViews() {

    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.back) {
            finish();
        } else if (id == R.id.set_nick_upload) {
            String nickName = editText.getText().toString();
            if (TextUtils.isEmpty(nickName)) {
                PubUtils.popTipOrWarn(this, "请输入一个昵称");
                return;
            }
            Intent intent = new Intent();
            intent.putExtra("nickName", nickName);// 把返回数据存入Intent
            ModifyUserInfoActivity.this.setResult(1, intent);// 设置回传数据。resultCode值是1，这个值在主窗口将用来区分回传数据的来源，以做不同的处理
            ModifyUserInfoActivity.this.finish();
        }
    }
}
